<?php

/**
 * 默认控制器
 */
class Controller_Default extends Controller_Abstract
{
    function actionIndex(){
    	
    	if( !isset($this->_view['posts']) ){

    		// 分页查询
			$page = intval($this->_context->page);
			if ($page < 1) $page = 1;
			// 构造查询对象	
			$select = $this->_view['posts'] = Posts::find(" `type` = 'news' AND `status` = 'publish' ")
												->Order(' ID DESC')->limitPage($page,10);
			// 将分页信息和查询到的数据传递到视图
			$this->_view['pagination'] = $select->getPagination();
			$this->_view['posts'] = $select->getAll();
		
    		//	dump($this->_view['posts']);
    	}
    	$this->_viewname = 'news_index';
    }
}

